package app.caretrack.teststruts;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class DropdownAction extends Action {
    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        System.out.println("DropdownAction.execute");
        if (isCancelled(request)) {
            return mapping.findForward("falure");
        }
        String hello = request.getParameter("hello");
        DropdownForm dForm = (DropdownForm) form;
        List savedViews = new ArrayList();
        DropdownItem di1 = new DropdownItem();
        di1.setValue("a");
        di1.setLabel("A");
        DropdownItem di2 = new DropdownItem();
        di2.setValue("b");
        di2.setLabel("B");
        savedViews.add(di1);
        savedViews.add(di2);
        dForm.setSavedViews(savedViews);
        dForm.setMapViewId("c");
        return mapping.findForward("success");
    }
}
